using System;
using System.Collections.Generic;
using System.Text;

namespace MosziNET.Web.Gallery
{
    /// <summary>
    /// Contains information on a folder
    /// </summary>
    public class Folder
    {
        #region / Private fields /

        string folderId;
        string folderTitle;
        FolderImage thumbnail;

        #endregion / Private fields /
        
        #region / Properties /

        /// <summary>
        /// Gets/sets the folder id
        /// </summary>
        public string Id
        {
            get
            {
                return this.folderId;
            }
            set
            {
                this.folderId = value;
            }
        }

        /// <summary>
        /// Gets/sets the title of the folder
        /// </summary>
        public string Title
        {
            get
            {
                return this.folderTitle;
            }
            set
            {
                this.folderTitle = value;
            }
        }

        /// <summary>
        /// Gets/sets the thumbnail image for this folder
        /// </summary>
        public FolderImage Thumbnail
        {
            get
            {
                return this.thumbnail;
            }
            set
            {
                this.thumbnail = value;
            }
        }

        #endregion / Properties /
    }

    public class FolderImage
    {
        #region / Private fields /

        string imageName;
        string parentFolder;

        #endregion / Private fields /

        public FolderImage() : this(String.Empty, String.Empty)
        {
        }

        public FolderImage(string folderId, string imageName)
        {
            this.ParentFolder = folderId;
            this.ImageName = imageName;
        }

        public FolderImage(string fullImagePath)
        {
            if (String.IsNullOrEmpty(fullImagePath))
                throw new ArgumentNullException("fullImagePath");

            string[] tags = fullImagePath.Split('/');

            if (tags.Length != 2)
                throw new ArgumentException("fullImagePath");

            this.ParentFolder = tags[0];
            this.ImageName = tags[1];
        }

        #region / Properties /

        /// <summary>
        /// Gets/sets the image's name
        /// </summary>
        public string ImageName
        {
            get
            {
                return this.imageName;
            }
            set
            {
                this.imageName = value;
            }
        }

        /// <summary>
        /// Gets/sets the parent folder.
        /// </summary>
        public string ParentFolder
        {
            get
            {
                return this.parentFolder;
            }
            set
            {
                this.parentFolder = value;
            }
        }

        #endregion / Properties /
    }

}
